package dao_mysql

import (
	"onerk4/zk2/common/global"
	"onerk4/zk2/common/model"
)

func QueryUserByMobile(mobile string) (result *model.User, err error) {
	err = global.DB.Model(&model.User{}).Where("mobile = ?", mobile).Limit(1).Find(&result).Error
	if err != nil {
		return nil, err
	}
	return result, nil
}

func QuerySearchEnterpriseData(uid int64) (result []*model.EbStoreProduct, err error) {
	err = global.DB.Model(&model.EbStoreProduct{}).Where("mer_id = ?", uid).Find(&result).Error
	return
}

func QuerySearchEnterpriseDataLike(uid int64, name string) (result []*model.EbStoreProduct, err error) {
	err = global.DB.Model(&model.EbStoreProduct{}).Where("mer_id = ?", uid).Where("store_name LIKE ?", "%"+name+"%").Find(&result).Error
	return
}
